//
//  XZHIllustrationTableViewCell.m
//  Piece
//
//  Created by dllo on 16/6/11.
//  Copyright © 2016年 Northeast Dianli University. All rights reserved.
//

#import "XZHIllustrationTableViewCell.h"
#import "UIImageView+WebCache.h"

@implementation XZHIllustrationTableViewCell

- (void)setModel:(XZHIllustrationModel *)model
{
    
    if (_model != model) {
        _model = model;
        [self.leftImageView sd_setImageWithURL:[NSURL URLWithString:model.hp_img_url]];
        //self.contentsLabel.text = model.hp_content;
        //self.authorLabel.text = model.hp_author;
        
        NSMutableAttributedString *contentsAttributeString = [[NSMutableAttributedString alloc] initWithString:model.hp_content];
       
        NSRange range = [model.hp_content rangeOfString:self.strKey];
        [contentsAttributeString setAttributes:[NSMutableDictionary dictionaryWithObjectsAndKeys:[UIColor redColor], NSForegroundColorAttributeName, nil] range:range];
        self.contentsLabel.attributedText = contentsAttributeString;

        NSMutableAttributedString *authorAttributeString = [[NSMutableAttributedString alloc] initWithString:model.hp_author];
        
        NSRange authorRange = [model.hp_author rangeOfString:self.strKey];
        [authorAttributeString setAttributes:[NSMutableDictionary dictionaryWithObjectsAndKeys:[UIColor redColor], NSForegroundColorAttributeName, nil] range:authorRange];
        self.authorLabel.attributedText = authorAttributeString;

    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
